<template>
	<el-form ref="form" :model="form" label-width="80px">
		<el-form-item label="学号">
			<el-input v-model="form.sid"></el-input>
		</el-form-item>
		<el-form-item label="姓名">
			<el-input v-model="form.sname"></el-input>
		</el-form-item>
		<el-form-item label="性别">
			<!-- <el-input v-model="form.sex"></el-input> -->
			<el-radio v-model="form.sex" label="男">男</el-radio>
			<el-radio v-model="form.sex" label="女">女</el-radio>
		</el-form-item>
		<el-form-item label="出生日期">
			<el-date-picker v-model="form.birth" type="datetime" placeholder="选择日期时间">
			</el-date-picker>
		</el-form-item>
		<!-- <el-form-item label="教师">
        <el-select v-model="form.Teacher" placeholder="请选择活动区域">
            <el-option
                    v-for="item in teacherlist"
                    :key="item.TeaName"
                    :label="item.TeaName"
                    :value="item.TeaName">
            </el-option>
        </el-select>
    </el-form-item>
    <el-form-item label="deparmentno">
        <el-select v-model="form.DepartNo" placeholder="请选择活动区域">
            <el-option
                    v-for="item in DepartNos"
                    :key="item.DepartNo"
                    :label="item.DepartName"
                    :value="item.DepartNo">
            </el-option>
        </el-select>
    </el-form-item> -->
		<el-form-item label="专业">
			<!-- <el-input v-model="form.major"></el-input> -->
			<el-select v-model="form.value" placeholder="请选择">
				<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" >
				</el-option>
			</el-select>
		</el-form-item>

		<el-form-item>
			<el-button type="primary" @click="onSubmit">立即创建</el-button>
			<el-button>取消</el-button>
		</el-form-item>
	</el-form>
</template>
<script>
	// import qs from 'qs';
	const axios = require('axios');
	export default {
		data() {
			return {
				form: {
					sid: '',
					sname: '',
					sex: '',
					birth: this.birth,
					
					value: this.value,

				},
				
				pickerOptions: {
					shortcuts: [{
						text: '今天',
						onClick(picker) {
							picker.$emit('pick', new Date());
						}
					}, {
						text: '昨天',
						onClick(picker) {
							const date = new Date();
							date.setTime(date.getTime() - 3600 * 1000 * 24);
							picker.$emit('pick', date);
						}
					}, {
						text: '一周前',
						onClick(picker) {
							const date = new Date();
							date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
							picker.$emit('pick', date);
						}
					}]
				},
				birth: this.birth,
				options: [{
					value: '软件技术',
					label: '软件技术'
				}, {
					value: '网络与信息安全',
					label: '网络与信息安全'
				}, {
					value: '物联网',
					label: '物联网'
				}, {
					value: '工商管理',
					label: '工商管理'
				}, {
					value: '电子商务',
					label: '电子商务'
				}],
				value:this.value
			}
			
		},
		methods: {
			onSubmit() {
				if (this.form.sid == '' | this.form.sname == '' | this.form.sex == '' | this.form.birth == null |
					this.form.value == null ) {
					this.$message({
						message: '请把所有信息填写完整',
						center: true,
						type: 'error'
					});
					return;
				}
				console.log(this.form);
				console.log(this.form.birth);
				// let student = qs.stringify({
				// 	form: this.form,
					
				// });
				axios.put("http://localhost:8000/insert", this.form)
					.then((res) => {
						console.log(res)
						if (res.data == "success") {
							this.$message({
								message: '添加成功',
								center: true,
								type: 'success'
							});
							this.$router.push('/teamemu/list')
						} else {
							this.$message({
								message: '添加失败',
								center: true,
								type: 'error'
							});
						}

					})
					.catch((err) => {
						console.log(err)
						alert("err");
					})
			},
			
		},
		
	}
</script>
